﻿using Microsoft.AspNetCore.Http;

namespace Soul.IdentityServer.Endpoints
{
    public class DiscoveryEndpoint : EndpointBase
    {
        private readonly IDiscoveryService _discoveryService;

        public DiscoveryEndpoint(IDiscoveryService discoveryService)
        {
            _discoveryService = discoveryService;
        }

        public override async Task<EndpointResult> HandleAsync(HttpContext context)
        {
            var configuration = await _discoveryService.GetOpenIdConnectConfigurationAsync();
            return JsonResult(configuration);
        }
    }
}
